// with polyfills
import 'core-js/stable'
import 'regenerator-runtime/runtime'

import Vue from 'vue'
import App from './App.vue'
import router from './router'
import store from './store/'
import i18n from './locales'
import { VueAxios } from './utils/request'
import ProLayout, { PageHeaderWrapper } from '@ant-design-vue/pro-layout'
import themePluginConfig from '../config/themePluginConfig'
import { Transfer, AutoComplete, FormModel, Cascader } from 'ant-design-vue'
// mock
// WARNING: `mockjs` NOT SUPPORT `IE` PLEASE DO NOT USE IN `production` ENV.
// import './mock'

import bootstrap from './core/bootstrap'
import './core/lazy_use' // use lazy load components
import './permission' // permission control
import './utils/filter' // global filter
import './global.less' // global style
import moment from 'moment'
// import moment from 'moment'
// import * as momentTimezone from 'moment-timezone'
import 'moment/locale/zh-cn'
moment.locale('zh-cn')

Vue.config.productionTip = false

// mount axios to `Vue.$http` and `this.$http`
Vue.use(VueAxios)
Vue.use(Transfer)
Vue.use(AutoComplete)
Vue.use(FormModel)
Vue.use(Cascader)
// Vue.use(momentTimezone)
// use pro-layout components
Vue.component('pro-layout', ProLayout)
Vue.component('page-container', PageHeaderWrapper)
Vue.component('page-header-wrapper', PageHeaderWrapper)

window.umi_plugin_ant_themeVar = themePluginConfig.theme

Vue.prototype.Format = function (times, fmt) {
  const timeStr = new Date(times)
  var o = {
      'M+': timeStr.getMonth() + 1, // 月份
      'd+': timeStr.getDate(), // 日
      'h+': timeStr.getHours(), // 小时
      'm+': timeStr.getMinutes(), // 分
      's+': timeStr.getSeconds(), // 秒
      'q+': Math.floor((timeStr.getMonth() + 3) / 3), // 季度
      'S': timeStr.getMilliseconds() // 毫秒
  }
  if (/(y+)/.test(fmt)) fmt = fmt.replace(RegExp.$1, (timeStr.getFullYear() + '').substr(4 - RegExp.$1.length))
  for (var k in o) {
    if (new RegExp('(' + k + ')').test(fmt)) fmt = fmt.replace(RegExp.$1, (RegExp.$1.length === 1) ? (o[k]) : (('00' + o[k]).substr(('' + o[k]).length)))
  }
  return fmt
}

new Vue({
  router,
  store,
  i18n,
  // init localstorage, vuex
  created: bootstrap,
  render: h => h(App)
}).$mount('#app')
